home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Emulatoren / zxam20.lha / ZXAM Spectrum / ZXAM_Rexx / Español / Monitor.zxam < prev    next >
Encoding:
Text File  |  1995-01-21  |  6.7 KB  |  268 lines

  1. /* Este script es un mini-monitor de CM creado por Leonardo Cocaña Galán */
  2. /* Montado a partir de varios de los ejemplos que acompañan el ZXAM, y */
  3. /* con aportación propia, por supuesto! */
  4. /* Con el tiempo será bastante mejorado... */
  5.  
  6.     /* comprobamos si el emulador está presente */
  7.     address command
  8.     
  9.     if ~show(ports,ZXAM_REXX) then do
  10.         requestchoice 'title "ZXAM Script error..." body "No encuentro el puerto del emulador!!" gadgets "AARGH!"'
  11.         exit
  12.         end
  13.  
  14.     /* abrimos la ventana de salida */
  15.     if ~open('fichero','con:0/11/640/256/Ejemplo de uso de ZXAMDisassemble()','W') then exit
  16.     
  17.     dir=zxamgetreg(pc)
  18.     call desambla(dir,16)
  19.     call registros()
  20.  
  21. bucle:    /* debemos seguir? */
  22.     call print ('(S)eguir,(N)ewDir,Set(PC),(P)oke,P(E)ek,(R)un,')
  23.     dummy=writech('fichero','0a'x)
  24.     call print ('(T)race,Brea(K)Point,Re(L)oad,(B)asic,(Q)uit,(F)ind: ')
  25.     respuesta=input()
  26.     respuesta=upper(respuesta)    
  27.     if (respuesta='S'|respuesta='') then do 
  28.     call desambla(dir,16)
  29.     call registros ()
  30.     end
  31.     if respuesta='Q' then signal cleanup
  32.     if respuesta='N' then call newdir()
  33.     if respuesta='P' then call poke()
  34.     if respuesta='R' then do 
  35.         zxamrun()
  36.         dir=zxamgetreg(pc)
  37.         call desambla(dir,16)
  38.         call registros()
  39.     end
  40.     if respuesta='L' then do 
  41.         call reload
  42.         dir=zxamgetreg(pc)
  43.         call desambla(dir,16)
  44.         call registros()
  45.         end
  46.     if respuesta='B' then do 
  47.         call listbasic
  48.         signal bucle
  49.         end
  50.     if respuesta='PC' then     call setpc
  51.         if respuesta='F'  then  call Findblock
  52.     if respuesta='E'  then  call peek
  53.     if respuesta='T' then do 
  54.         dummy=zxamtrace()
  55.         dir=zxamgetreg(pc)
  56.         call desambla(dir,16)
  57.         call registros()
  58.         end
  59.     if respuesta='K' then call breakpoint
  60. signal bucle
  61.  
  62. Desambla:
  63.  
  64. Parse arg direccion,linias
  65. do i=1 to linias 
  66.         linea=zxamdisassemble(direccion,'d')        /* desensambla en decimal */
  67.         dummy=writech('fichero',substr(linea,2))
  68.         dummy=writech('fichero','0a'x)
  69.         direccion=(direccion+left(linea,1))            /* suma bytes que ocupa la inst */
  70.         if direccion>65535 then direccion=direccion-65536    
  71. dir = direccion
  72. end i
  73.  
  74. return
  75. registros:
  76. dummy=writech('fichero','0a'x)
  77. dummy=writech('fichero','BC  'zxamgetreg(bc,h))
  78. dummy=writech('fichero','     DE  'zxamgetreg(de,h))
  79. dummy=writech('fichero','     HL  'zxamgetreg(hl,h))
  80. dummy=writech('fichero',"     BC' "zxamgetreg(bc2,h))
  81. dummy=writech('fichero',"     DE' "zxamgetreg(de2,h))
  82. dummy=writech('fichero',"     HL' "zxamgetreg(hl2,h))
  83. dummy=writech('fichero','0a'x)
  84.         
  85. dummy=writech('fichero','IX  'zxamgetreg(ix,h))
  86. dummy=writech('fichero','     IY  'zxamgetreg(iy,h))
  87. dummy=writech('fichero','     SP  'zxamgetreg(sp,h))
  88. dummy=writech('fichero','     PC  'zxamgetreg(pc,h))
  89. dummy=writech('fichero','      I  'zxamgetreg('i',h))
  90. dummy=writech('fichero','        R  'zxamgetreg(r,h))
  91. dummy=writech('fichero','0a'x)
  92. dummy=writech('fichero'," A  "zxamgetreg(a,h))
  93. dummy=writech('fichero',"        F  "zxamgetreg(f,h))
  94. dummy=writech('fichero',"        A' "zxamgetreg(a2,h))
  95. dummy=writech('fichero',"        F' "zxamgetreg(f2,h))
  96.  
  97. dummy=writech('fichero','       IM'zxamgetreg(im))
  98. dummy=writech('fichero','          INT 'zxamgetreg(int))
  99.  
  100. dummy=writech('fichero','0a'x)
  101. dummy=writech('fichero','0a'x)
  102.         
  103. dummy=writech('fichero','S   Z   -   H   -  P/V  N   C')
  104. dummy=writech('fichero','0a'x)
  105.         
  106. dummy=writech('fichero',bittst(d2c(zxamgetreg(f)),7))
  107. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),6))
  108. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),5))
  109. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),4))
  110. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),3))
  111. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),2))
  112. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),1))
  113. dummy=writech('fichero','   'bittst(d2c(zxamgetreg(f)),0))
  114. dummy=writech('fichero','0a'x)
  115. dummy=writech('fichero','0a'x)
  116. return
  117. cleanup:
  118.  
  119.     dummy=close('fichero')
  120.  
  121.     exit
  122. newdir:
  123. call print ('Dirección PC: ')
  124. dir=input()
  125. if (dir>65535 | dir<0)  then signal newdir
  126. call desambla(dir,16)
  127. call registros()
  128. return
  129.  
  130. peek:
  131. call print ('PEEK: ')
  132. pek=input()
  133. if (dir>65535 | dir<0)  then signal peek
  134. call print (zxampeek(pek))
  135. dummy=writech('fichero','0a'x)
  136. return
  137. poke:
  138. call print ('POKE ')
  139. pok=input()
  140. if length(pok)<7 then signal error_long
  141. dirpoke=left(pok,(lastpos(",",pok)-1))
  142. valor=right(pok,(length(pok)-lastpos(',',pok)))
  143. if (dirpoke<16384 | dirpoke>65535) then signal error_dir
  144. if (valor<0 |valor>255) then signal error_val
  145. zxampoke(dirpoke,valor)
  146. return
  147.  
  148. Print:
  149. parse arg texto
  150. dummy=writech('fichero',texto)
  151. return
  152.  
  153. Input:
  154. return readln('fichero')
  155.  
  156. Reload:
  157. zxamparseloaded(zxampploadfile(zxamjoinpathname(zxamactloadpath(),zxamactname())))
  158. return
  159.  
  160. Listbasic:
  161. /* este script saca el listado del BASIC presente en la memoria del */
  162. /* Spectrum y lo graba como fichero */
  163.     
  164.  
  165.     /* debemos listar el BASIC. primero lo localizamos */
  166.     
  167.     /* dir inicio del BASIC (variable PROG) */
  168.     baselist=zxamdpeek(23635)
  169.     
  170.     /* longitud del programa BASIC (con variable VARS) */
  171.     endlist=zxamdpeek(23627)
  172.     
  173.     /* calculamos tamaño */
  174.     longbasic=endlist-baselist
  175.     if longbasic=0 then do
  176.         requestchoice '>nil: title "ZXAM Script error..." body "No hay programa BASIC!!" gadgets "AARGH!"'
  177.         return
  178.         end
  179.     
  180.     /* cogemos toda el area BASIC */
  181.     bloquebasic=zxamgetmem(baselist,endlist-baselist)
  182.  
  183.  
  184.     do forever    
  185.     /* procesamos la linea */
  186.         
  187.         /* imprimimos numero de linea */
  188.         numlinea=c2d(left(bloquebasic,2))
  189.         dummy=writech('fichero','  'numlinea)
  190.         longline=c2d(reverse(substr(bloquebasic,3,2))) /* fomato invertido Z80 */
  191.         do i=5 to 4+longline    /* para procesar los caracteres de la linea */
  192.         if substr(bloquebasic,i,1)='0e'x then do
  193.             i=i+5
  194.             iterate
  195.             end
  196.         dummy=writech('fichero',zxambasictoken(substr(bloquebasic,i,1)))
  197.         
  198.         
  199.         end i
  200.         
  201.     dummy=writech('fichero','0a'x)
  202.     
  203.     bloquebasic=right(bloquebasic,length(bloquebasic)-(longline+4))
  204.     if bloquebasic='' then break
  205.     end
  206. return
  207.  
  208. Setpc:
  209.  
  210. call print ('PC :')
  211. pcdir=input()
  212. if (pcdir>65535 | pcdir<0) then signal setpc
  213. zxamsetreg(pc,pcdir)
  214. dir=zxamgetreg(pc)
  215. call desambla(dir,16)
  216. call registros()
  217. return
  218.  
  219. Error_dir:
  220.  
  221. Call Print ('ERROR DIRECCION FUERA DE MARGEN (16384-65535)')
  222. dummy=writech('fichero','0a'x)
  223. Signal poke
  224.  
  225. Error_val:
  226.  
  227. Call print ('ERROR VALOR FUERA DE MARGEN (0-255)')
  228. dummy=writech('fichero','0a'x)
  229. Signal poke
  230.  
  231. Error_long:
  232.  
  233. Call print ('ERROR PARAMETROS INCORRECTO (POKE 60000,255)')
  234. dummy=Writech('fichero','0a'x)
  235. signal poke
  236.  
  237. error_noblock:
  238.  
  239. call print ('BLOQUE DE DATOS NO ENCONTRADO')
  240. dummy=writech('fichero','0a'x)
  241. return
  242.  
  243. Findblock:
  244. direc=23296
  245. call print ('Inserte datos a buscar (hex):') 
  246. block=x2c(input())
  247. bucle1:
  248. call busca(direc)
  249. if direc<=-1 then do
  250. call error_noblock
  251. return
  252. end
  253. call desambla(direc,3)
  254. direc=dir
  255. signal bucle1
  256. return
  257. busca:
  258. parse arg comienzo
  259. direc=zxamfindblock(comienzo,block)
  260. return
  261.  
  262. breakpoint:
  263. call print('Direccion Break Point: ')
  264. break=input()
  265. if (break<0 |break>65535) then signal breakpoint
  266. zxambreakpoint(break)
  267. return
  268.